cmake_minimum_required(VERSION 3.5)
project(pubsub_yuan)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

SET(CMAKE_BUILD_TYPE "RELEASE")
SET(CMAKE_CXX_FLAGS "-O2 -g ${CMAKE_CXX_FLAGS}")

find_package(ament_cmake_auto REQUIRED)
find_package(OpenCV REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(PCL REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(pcl_conversions REQUIRED)

ament_auto_find_build_dependencies()

include_directories(
  include
  ${OpenCV_INCLUDE_DIRS}
  ${PCL_INCLUDE_DIRS}
)


############### listener node ###############

ament_auto_add_library(${PROJECT_NAME}_sub_node SHARED
  include/sub.hpp
  src/sub.cpp
)

target_link_libraries(${PROJECT_NAME}_sub_node ${OpenCV_LIBRARIES} ${PCL_LIBRARIES} ${cv_bridge_LIBRARIES})

rclcpp_components_register_node(${PROJECT_NAME}_sub_node
  PLUGIN "mars_rover::sub_yuan::SubscriberNode"
  EXECUTABLE ${PROJECT_NAME}_sub_exe
)

############### talker node ###############

ament_auto_add_library(${PROJECT_NAME}_pub_node SHARED
  include/pub.hpp
  src/pub.cpp
)

target_link_libraries(${PROJECT_NAME}_pub_node  ${OpenCV_LIBRARIES} ${PCL_LIBRARIES} ${cv_bridge_LIBRARIES})


rclcpp_components_register_node(${PROJECT_NAME}_pub_node
  PLUGIN "mars_rover::pub_yuan::PublisherNode"
  EXECUTABLE ${PROJECT_NAME}_pub_exe
)

# INSTALL
ament_auto_package(INSTALL_TO_SHARE launch param)